<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="/bootstrap.css">
    <style>
        .container{
            width:500px;
            margin:20px auto;
        }
        .add{
            width: 100%;
            height:40px;
            font-size:35px;
            text-align: center;
            line-height:40px;

        }
        body{
            background:#ccc;
        }
    </style>
</head>

<body>

    <div class="container">
        <div class="add">信息添加</div>
        <p class="form-group">
            <label for="username">username:</label>
            <input type="text" name="username" class="form-control">
        </p>
        <p class="form-group">
            <label for="age">age:</label>
            <input type="text" name="age" class="form-control">
        </p>
        <p class="form-group">
            <input type="radio" name="sex" value="boy">boy
            <input type="radio" name="sex" value="girl">girl
        </p>
        <p class="form-group">
            <label for="phone">phone:</label>
            <input type="text" name="phone" class="form-control">
        </p>
        <p class="form-group">
            <input type="button" value="save" onclick="save()" class="btn btn-success">
            <a href="/sql.html">返回</a>
        </p>
    </div>
</body>
<script src="/jquery.min.js"></script>
<script>
    function save() {
        var username = $('[name="username"]').val()
        var age = $('[name="age"]').val()
        var sex =$('input:radio:checked').val()
        var phone =$('[name=phone]').val()
            $.post('/users/add', {
                username: username,
                age: age,
                sex:sex,
                phone:phone
            }).done(function (res) {
                location.href = './sql.html'
                console.log(res);
            })
    }
</script>

</html>